home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / util / rexx / fw_macros.lha / Remove_Section < prev    next >
Encoding:
Text File  |  1995-03-26  |  3.1 KB  |  116 lines

  1. /* ======================================== */
  2. /*  FINAL WRITER AREXX MACRO                */
  3. /*    by Nigel S. Domaingue, 28/1/95        */
  4. /*                                          */
  5. /*  Script to remove undesired Sections.    */
  6. /*  $Ver:  Remove_Section 1.0 (28/1/95)     */
  7. /* ======================================== */
  8.  
  9. /* Allows user to move to remove any Main section.  */
  10. /* Only use if there are less than 6 sections.      */
  11.  
  12. Options Results
  13.  
  14. GetSectionList ","
  15. listing = Result
  16.  
  17. /* Set up a stem (i.e. array) */
  18. x. = Section
  19. y. = '""'
  20.  
  21. /* Split 'listing' into component parts */
  22. /* and put those into the x. stem.      */
  23. PARSE VAR listing x.1 ',' x.2 ',' x.3 ',' x.4 ',' x.5 ',' x.6 ',' x.7 ',' x.8 ',' x.9 ',' x.10
  24. do i = 1 to 10
  25.       IF ( LENGTH(x.i) = 0 ) THEN
  26.       Do
  27.          n = i-1
  28.          i = 10
  29.       end
  30. end
  31.  
  32. /* If the document only has one section */
  33. /* there are three options:             */
  34. /*   1) Close that document only        */
  35. /*   2) Quit the whole program          */
  36. /*   3) Do nothing (Exit the script)    */
  37.  
  38. If ( n = 1 ) THEN
  39.    ShowMessage 3 1 '"This document only has one section" "Quit the document?" "" "Close Document" "Quit FW" "Cancel"'
  40.    If ( Result = 1 ) Then Close
  41.    If ( Result = 2 ) Then Quit
  42.    If ( Result = 3 ) Then Exit
  43.  
  44. /* This section of the script is labelled so that it can */
  45. /* be returned to later if required.                     */
  46.  
  47. getinput:
  48.    m=0
  49.    RequestText  '"Choose section to remove." "Pattern to match: (Case insensitive)" ""'
  50.       choice = Upper(Result)
  51.       len = Length(choice)
  52.       Do i = 1 to n
  53. /* If pattern matches part of an available section  */
  54. /* 'first' will return the position of the first    */
  55. /* character in the matched sequence. (non zero)    */
  56. /*   If there is more than one match (i.e. a vague  */
  57. /* pattern), the script will detect this.           */
  58.  
  59.          first = index(Upper(x.i),choice)
  60.             if (first~=0) Then
  61.                Do
  62.                   m=m+1
  63.                   y.m = '"'x.i'"'
  64.                end
  65.       end
  66.  
  67.  
  68. If ( m = 0 ) Then
  69.    Do
  70.       firstline = '"Section 'choice' not found."'
  71.       ShowMessage 1 0 firstline '"(You might have mis-spelled it)." "" "Try Again  " "Cancel" ""'
  72.       If ( Result = 1 ) Then  Signal 'getinput'
  73.       Else NOP
  74.       Exit
  75.    end
  76.  
  77. If ( m = 1 ) Then
  78.    Do
  79.       RemoveSection y.1
  80.       Exit
  81.    End
  82.  
  83. If ( m <= 3 ) Then
  84.    Do
  85.       firstline = '"'m' Sections match your pattern."'
  86.       ShowMessage 1 0 firstline '"Which one to remove?" ""' y.1 y.2 y.3
  87.       del = Result
  88.       RemoveSection y.del
  89.       Exit
  90.    End
  91.  
  92. If ( m <= 5 ) Then
  93.    Do
  94.       firstline = '"'m' Sections match your pattern."'
  95.       ShowMessage 3 0 firstline '"Which one to remove?" ""' y.1 y.2 '"Next List  "'
  96.       del = Result
  97.       If ( del = 3 ) Then
  98.          Do
  99.             ShowMessage 1 0 '"Which One to remove?" "" ""' y.3 y.4 y.5
  100.             del = Result + 2
  101.          End
  102.       Else NOP
  103.       RemoveSection y.del
  104.       Exit
  105.    End
  106.  
  107. If ( m > 5 ) Then
  108.    Do
  109.       ShowMessage 1 0 '"There are more than 5 matches to your pattern." "Either use a more reliable pattern, or" "use the menus." "Silly me" "" ""'
  110.       Exit
  111.    End
  112.  
  113.  
  114.  
  115.  
  116.